package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class PerformALinearSearchForAnIntegerInAGivenArray {
	public static int linearSearch(int[] array, int i) {
		for (int c = 0, len = array.length; c < len; ++c) {
			if (array[c] == i) {
				return c;
			}
		}
		return -1;
	}

	public static int linearSearch(long[] array, long l) {
		return linearSearch(array, 0, array.length, l);
	}

	public static int linearSearch(long[] array, int start, int end, long l) {
		for (int c = start; c < end; ++c) {
			if (array[c] == l) {
				return c;
			}
		}
		return -1;
	}
}
